#pragma once
#include <windows.h>


#define CPU_HISTORY_MAX 100

class CPUMeasure
{
public:
	CPUMeasure(void);
public:
	~CPUMeasure(void);
	void Measure();
	bool bEnd;
	char chCPUHistory[CPU_HISTORY_MAX];

	inline void PushValue(char percent)
	{
		MoveMemory(chCPUHistory+1, chCPUHistory, CPU_HISTORY_MAX-1);
		*chCPUHistory = percent;
	}	

	inline char PopValue()
	{
		return(*chCPUHistory);
	}

protected:
	HANDLE hIdleThread;
	
	bool ThreadCreate(void);
	static DWORD idleThread(LPVOID lpParameter);
	DWORD GetThreadTick(FILETIME* a, FILETIME* b);
	void KillThread();
private:
	DWORD	dwLastThreadTime;
	DWORD	dwLastTickTime;
};
